﻿@model Alma.Models.AdvancedSearchModel
@{
    ViewBag.Title = "Advanced";
    ViewContext.Controller.ViewBag.Breadcrumb.Enter("Recherche", "Index", "Search");
    ViewContext.Controller.ViewBag.Breadcrumb.Enter("Avancée");
}

<div class="fullcol">
<h1>Recherche avancée</h1>

@using (Html.BeginForm("Advanced", "Search", FormMethod.Post))
{

<p>Vous recherchez...</p>

<dl>

<dt><label for="AllWords">...<em>tous</em> les mots suivants</label></dt>
<dd>@Html.TextBox("AllWords", Model.AllWords)</dd>

<dt><label for="Expression">...cette <em>expression exacte</em></label></dt>
<dd>@Html.TextBox("Expression", Model.Expression)</dd>

<dt><label for="SomeWords">...<em>au moins un</em> des mots suivants</label></dt>
<dd>@Html.TextBox("SomeWords", Model.SomeWords)</dd>

<dt><label for="NoneWord">...<em>aucun</em> des mots suivants</label></dt>
<dd>@Html.TextBox("NoneWord", Model.NoneWord)</dd>

</dl><dl class="separated">

<dt><label for="Category">Catégorie</label></dt>
<dd>@Html.DropDownList("Category", Model.CategoriesItems, "(peu importe)")</dd>

<dt><label for="Section">Section</label></dt>
<dd>@Html.DropDownList("Section", Model.SectionItems, "(peu importe)")</dd>

</dl>

if (Model.Criterions.Count > 0)
{
    var i = 1;
<dl class="separated">

@{var operators = new List<SelectListItem>()
    {
        new SelectListItem() { Text = "contient", Value = "#" },
        new SelectListItem() { Text = "égale", Value = "=" },
        new SelectListItem() { Text = "supérieur à", Value = ">" },
        new SelectListItem() { Text = "inférieur à", Value = "<" },
    }; }

@foreach (var crit in Model.Criterions)
{
    <dt>@Html.TextBox("CriterionTarget" + i.ToString(), crit.Target, new Dictionary<string, object>() { {"style", "width: 200px;"} })</dt>

    foreach (var o in operators)
    {
        o.Selected = (o.Value == crit.Operator);
    }
    <dd>
        @Html.DropDownList("CriterionOperator" + i.ToString(), operators, "", new Dictionary<string, object>() { { "style", "width: 140px;" } })
        @Html.TextBox("CriterionValue" + i.ToString(), crit.Value, new Dictionary<string, object>() { { "style", "width: 140px;" } })
    </dd>
    i += 1;
}

@Html.Hidden("CriterionCount", i - 1)
</dl>
}

<p>
    <button type="submit" name="Action" value="Search">Rechercher</button>
    <button type="submit" name="Action" value="AddCriterion">Ajouter un critère</button>
    
    @*
    @if (Request["s"] != null)
    {
        @: <a style="margin: 0 0 0 6px;" href="@Url.Action("Index", "Search", new RouteValueDictionary() { { "s", Request["s"] } })">modifier la requête simple</a>
    }
    *@
</p>

    
}

</div>